/********************************************************************
	created:	2008/09/29
	created:	29:9:2008   17:34
	filename: 	h:\SimoneEngine\qianye\src\qylib\filesys\qySingleton.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/

#pragma once

#ifndef __QYSINGLETON_H__
#define __QYSINGLETON_H__

#include "qyCommon.h"

/*
===========================================
class qySingleton
===========================================
*/
template < class T >
class qySingleton
{
protected:
	static T *m_sSingleton;
public:
	qySingleton( void )
	{
		assert( !m_sSingleton );
		m_sSingleton = static_cast<T*>(this);
	}
	~qySingleton( void )
	{  assert( m_sSingleton );  m_sSingleton = 0;  }
	static T& GetSingleton( void )
	{  assert( m_sSingleton );  return ( *m_sSingleton );  }
	static T* GetSingletonPtr( void )
	{  return ( m_sSingleton );  }
};

#endif
